﻿using Autofac;
using uMVP;
using uMVP.AutofacExtends;

namespace ExceptionModule
{
    public class ExceptionModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<LogConfiguration>().As<ILogConfiguration>().SingleInstance();
            builder.RegisterType<LogHandler>().As<ICustomLogHandler>().SingleInstance();
            builder.RegisterType<LogToConsole>().Keyed<ICustomLogHandler>(LogHandleType.LogToConsole).SingleInstance();
            builder.RegisterType<LogToFile>().Keyed<ICustomLogHandler>(LogHandleType.LogToFile).SingleInstance();
            builder.RegisterType<LogToUI>().Keyed<ICustomLogHandler>(LogHandleType.LogToUI).SingleInstance();
            
            builder.RegisterType<ExceptionStartUp>();
            builder.RegisterType<ExceptionManager>().As<IExceptionManager>();
            builder.RegisterView<IExceptionMessageBox, ExceptionMessageBox>();
            builder.RegisterType<LogExceptionHandler>()
                .As<IExceptionHandler>()
                .AsSelf()
                .SingleInstance();
            
            builder.RegisterModule<MvpModule>();
        }
    }
}